<?php

class BuyerController extends Core_FE_Controller {
    public function __construct() {
        parent::__construct();
        $this->template->set_template('customer');

        $this->template->parse_view('head', $this->include_view . '/customer/head', $this->data);
        $this->template->parse_view('header', $this->include_view . '/customer/header', $this->data);
        $this->template->parse_view('footer', $this->include_view . '/customer/footer', $this->data);
        $this->template->parse_view('footer_js', $this->include_view . '/customer/footer_js', $this->data);
    }

    public function index() {
        $params = $this->input->post();
        if (empty($params) == FALSE) {
            $this->load->library('Mailer');
            $data_send = array(
                'estate_type' => $params['estate_type'],
                'city' => $params['city'],
                'district' => $params['district'],
                'area' => $params['area'],
                'price' => $params['price'],
                'fullname' => $params['fullname'],
                'phone' => $params['phone'],
                'email' => $params['email'],
                'note' => $params['note'],
            );
            $this->mailer->send($data_send);
            redirect(base_url('buyer/success'));
        }

        $this->template->add_js('assets/default/js/buyer/script.js');
        $this->template->parse_view('content', $this->page_view . '/buyer/index', $this->data);
        $this->template->render();
    }

    public function success(){
        $this->template->parse_view('content', $this->page_view . '/buyer/success', $this->data);
        $this->template->render();
    }

}